import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

import path from "path";

// 自动导入vue
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
//自动导入elementplus
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
// 自动 导入非组件模块
import ElementPlus from "unplugin-element-plus/vite";

//vite  开发工具 dev-tools类似于
import VueDevTools from "vite-plugin-vue-devtools";

//ele
import Icons from "unplugin-icons/vite";
import IconsResolver from "unplugin-icons/resolver";
//jsx
import vueJsx from "@vitejs/plugin-vue-jsx";

export default defineConfig({
  server: {
    open: "/",

    proxy: {
      "/api": {
        target: "http://syt.atguigu.cn",
        changeOrigin: true,
      },
    },
    //automatically open app in browser the value is url
  },
  plugins: [
    vue(),
    VueDevTools(),
    ElementPlus({
      useSource: true,
    }),
    //自动引入vue
    AutoImport({
      imports: ["vue"],
      resolvers: [
        ElementPlusResolver(),
        IconsResolver({
          prefix: "Icon",
        }),
      ],
    }),
    Components({
      resolvers: [
        // 自动注册图标组件
        IconsResolver({
          enabledCollections: ["ep"],
        }),
        ElementPlusResolver(),
      ],
    }),

    Icons({
      /* options */
      autoInstall: true,
    }),

    vueJsx(),
  ],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@use "@/assets/style/uni.scss" as *;', //全局样式 编写自己的uni.scss
      },
    },
  },

  resolve: {
    alias: {
      "@": path.join(__dirname, "src"),
    },
    extensions: [".js", ".json", ".ts"], // 使用路径别名时想要省略的后缀名，可以自己 增减
  },
});
